from django.db import models

# Create your models here.


class Goods_info(models.Model):
    id = models.AutoField(primary_key=True)
    goods_name = models.CharField(max_length=64,null=False)
    goods_type = models.CharField(max_length=64,null=False)
    goods_price = models.DecimalField(max_digits=8,decimal_places=0)
    unit = models.CharField(max_length=10)
    remarks = models.CharField(max_length=1000)
    delete_flag = models.IntegerField(default=0)
    create_time = models.DateTimeField(auto_now_add=True)  # 创建时间
    update_time = models.DateTimeField(auto_now=True)  # 最后更新时间

class Customer_info(models.Model):
    id = models.AutoField(primary_key=True)
    order_num = models.CharField(max_length=64)
    order_time = models.DateTimeField()
    customer_name = models.CharField(max_length=64)
    customer_phone =models.CharField(max_length=13)
    customer_adr = models.CharField(max_length=255)
    deal_money = models.DecimalField(max_digits=8,decimal_places=0)
    deposit_money = models.DecimalField(max_digits=8,decimal_places=0)
    rest_money = models.DecimalField(max_digits=8,decimal_places=0)
    ruler_flag = models.IntegerField(default=0)
    delivery_flag = models.IntegerField(default=0)
    delivery_time = models.CharField(max_length=64)
    clean_status = models.IntegerField(default=0)
    remarks = models.CharField(max_length=1000)
    create_time = models.DateTimeField(auto_now_add=True)  # 创建时间
    update_time = models.DateTimeField(auto_now=True)  # 最后更新时间
    delete_flag = models.IntegerField(default=0)

class Order_detail(models.Model):
    id = models.AutoField(primary_key=True)
    space_name = models.CharField(max_length=64)
    goods_id = models.ForeignKey(to='Goods_info',on_delete=models.CASCADE)
    customer_id = models.ForeignKey(to='Customer_info',on_delete=models.CASCADE)
    deal_unit = models.DecimalField(max_digits=8,decimal_places=0)
    goods_nums = models.IntegerField(default=0)
    area = models.DecimalField(max_digits=8,decimal_places=2)
    deal_total = models.DecimalField(max_digits=8,decimal_places=0,default=0)
    delivery_time = models.CharField(max_length=64)
    remarks = models.CharField(max_length=1000)
    create_time = models.DateTimeField(auto_now_add=True)  # 创建时间
    update_time = models.DateTimeField(auto_now=True)  # 最后更新时间
    delete_flag = models.IntegerField(default=0)


